package cn.demoxy.config;

import cn.demoxy.properties.MinioProperties;
import io.minio.MinioClient;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @auther demo
 * @date 2022/5/24 17:19
 * minio配置类
 */
@Configuration
@Slf4j
@AllArgsConstructor
public class MinioConfig {

    private MinioProperties minioProperties;

    /**
     * 获取 MinioClient
     *
     * @return MinioClient
     */
    @Bean
    public MinioClient minioClient() {
        log.info("============minio配置已生效==============");
        return MinioClient.builder().endpoint(minioProperties.getEndpoint()).
                credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey()).build();
    }
}
